<?php
namespace Backend\Config;

use Backend\Controllers\Car\KulalaController;
use Backend\Controllers\Car\LotteryController;
use Backend\Controllers\Car\ServerRoleController;
use Backend\Controllers\Car\ServerTypeController;
use Backend\Controllers\Control\ActivityController;
use Phalcon\Mvc\Router\Annotations as RouterAnnotations;

/**
 * 加载路由
 */
$router = new RouterAnnotations(false);

$router->setDefaultNamespace('Backend\Controllers');
$router->setDefaultController('index');
$router->setDefaultAction('index');
$router->setUriSource(RouterAnnotations::URI_SOURCE_SERVER_REQUEST_URI);
$router->removeExtraSlashes(true);

$router->notFound([
    'namespace'  => 'Backend\Controllers',
    'controller' => 'error',
    'action'     => 'show404'
]);

$router->add('/index.php', [
    'namespace'  => 'Backend\Controllers',
    'controller' => 'index',
    'action'     => 'index',
]);

$router->add('/', [
    'namespace'  => 'Backend\Controllers',
    'controller' => 'index',
    'action'     => 'index',
]);
$router->add('/:controller', [
    'namespace'  => 'Backend\Controllers',
    'controller' => 1,
    'action'     => 'index',
]);
$router->add('/:controller/:action/:params', [
    'namespace'  => 'Backend\Controllers',
    'controller' => 1,
    'action'     => 2,
    'params'     => 3
]);
$router->add('/setting/sys/:controller/:action/:params', [
    'namespace'  => 'Backend\Controllers\Setting\Sys',
    'controller' => 1,
    'action'     => 2,
    'params'     => 3
]);
$router->add('/setting/my/:controller/:action/:params', [
    'namespace'  => 'Backend\Controllers\Setting\My',
    'controller' => 1,
    'action'     => 2,
    'params'     => 3
]);
$router->add('/member/:controller/:action/:params', [
    'namespace'  => 'Backend\Controllers\Member',
    'controller' => 1,
    'action'     => 2,
    'params'     => 3
]);
$router->add('/serverplatform/task/:controller/:action/:params', [
    'namespace'  => 'Backend\Controllers\ServerPlatform\Task',
    'controller' => 1,
    'action'     => 2,
    'params'     => 3
]);
$router->addResource(substr(ServerTypeController::class, 0, -10), '/car/servertype');
$router->addResource(substr(ServerRoleController::class, 0, -10), '/car/serverrole');
$router->addResource(substr(ActivityController::class, 0, -10), '/control/activity');
$router->addResource(substr(LotteryController::class, 0, -10), '/car/lottery');
$router->addResource(substr(KulalaController::class, 0, -10), '/car/kulala');

return $router;
